The various graphs I created can be viewed by selecting "download."
For my redo of my midterm I have fixed the images so that they can be seen by others.
My hypothesis is that the data I am analyzing will show that overall people feel "warmer" towards "whiteppl" than they do "blacks." Through box plots, violin plots, histograms, and kernel density plots; this hypothesis proves to be true. I also have added a regression analysis.
The two boxplots show how "warmly" or "coldly" people feel towards white and black people. The magenta graph is representative of "whiteppl" and the blue graph is representative of "blacks." There are a couple of outliers on the blue graph which means that some people feel extremely cold towards black people. However, the median of the graph is around 50 which means that 50% of people felt colder than that, and 50% felt warmer. On the magenta graph, it shows that the median is around 70. Overall, according to the graph people felt more warmly towards white people than black people.
This histogram shows the frequency of people's responses when asked how warmly they felt towards "blacks." The bars that are the tallest show that a large amount of people gave this response.
This histogram shows the frequency of people's responses when asked how warmly they felt towards "whiteppl." The bars that are the tallest show that a large amount of people gave this response.
Correlation between data on variables "Whiteppl" and "Blacks" 0.52
Regression Analysis shows that there is in fact a statistically significant relationship between how people feel towards "blacks" and how people feel towards "whiteppl" ("warm" or "cold").
#This R Script finds Descriptive Statistics for the variables “whiteppl” and “blacks,” finds the correlation between the two variables, and also creates boxplots, violin plots, histograms, and scatter plots for both variables.
#R SCRIPT install.packages("foreign") #install package to read in .dta files library(foreign) #load it nes<-read.dta("anes2008.dta") #read in data file from working directory, #and call it "nes". Takes a minute.
nes$V085064k[nes$V085064k=="-2"] <- NA #for each selected variable, replace nes$V085064k[nes$V085064k=="-6"] <- NA #negative values with "NA" and nes$V085064k[nes$V085064k=="-8"] <- NA #generate new variable with nes$V085064k[nes$V085064k=="-9"] <- NA #more intuitive name! poorppl<-nes$V085064k
nes$V085064n[nes$V085064n=="-2"] <- NA nes$V085064n[nes$V085064n=="-6"] <- NA nes$V085064n[nes$V085064n=="-8"] <- NA nes$V085064n[nes$V085064n=="-9"] <- NA bigbiz<-nes$V085064n
nes$V085064p[nes$V085064p=="-2"] <- NA nes$V085064p[nes$V085064p=="-6"] <- NA nes$V085064p[nes$V085064p=="-8"] <- NA nes$V085064p[nes$V085064p=="-9"] <- NA welfareppl<-nes$V085064p
nes$V085064d[nes$V085064d=="-2"] <- NA nes$V085064d[nes$V085064d=="-6"] <- NA nes$V085064d[nes$V085064d=="-8"] <- NA nes$V085064d[nes$V085064d=="-9"] <- NA feminists<-nes$V085064d
nes$V085064b[nes$V085064b=="-2"] <- NA nes$V085064b[nes$V085064b=="-6"] <- NA nes$V085064b[nes$V085064b=="-8"] <- NA nes$V085064b[nes$V085064b=="-9"] <- NA cfundamentals<-nes$V085064b
nes$V085064e[nes$V085064e=="-2"] <- NA nes$V085064e[nes$V085064e=="-6"] <- NA nes$V085064e[nes$V085064e=="-8"] <- NA nes$V085064e[nes$V085064e=="-9"] <- NA fedgov<-nes$V085064e
nes$V085064h[nes$V085064h=="-2"] <- NA nes$V085064h[nes$V085064h=="-6"] <- NA nes$V085064h[nes$V085064h=="-8"] <- NA nes$V085064h[nes$V085064h=="-9"] <- NA midclass<-nes$V085064h
nes$V085064m[nes$V085064m=="-2"] <- NA nes$V085064m[nes$V085064m=="-6"] <- NA nes$V085064m[nes$V085064m=="-8"] <- NA nes$V085064m[nes$V085064m=="-9"] <- NA military<-nes$V085064m
nes$V085064r[nes$V085064r=="-2"] <- NA nes$V085064r[nes$V085064r=="-6"] <- NA nes$V085064r[nes$V085064r=="-8"] <- NA nes$V085064r[nes$V085064r=="-9"] <- NA workclass<-nes$V085064r
nes$V085064u[nes$V085064u=="-2"] <- NA nes$V085064u[nes$V085064u=="-6"] <- NA nes$V085064u[nes$V085064u=="-8"] <- NA nes$V085064u[nes$V085064u=="-9"] <- NA gays<-nes$V085064u
nes$V085064v[nes$V085064v=="-2"] <- NA nes$V085064v[nes$V085064v=="-6"] <- NA nes$V085064v[nes$V085064v=="-8"] <- NA nes$V085064v[nes$V085064v=="-9"] <- NA asians<-nes$V085064v
nes$V085064y[nes$V085064y=="-2"] <- NA nes$V085064y[nes$V085064y=="-6"] <- NA nes$V085064y[nes$V085064y=="-8"] <- NA nes$V085064y[nes$V085064y=="-9"] <- NA blacks<-nes$V085064y
nes$V085064z[nes$V085064z=="-2"] <- NA nes$V085064z[nes$V085064z=="-6"] <- NA nes$V085064z[nes$V085064z=="-8"] <- NA nes$V085064z[nes$V085064z=="-9"] <- NA southerners<-nes$V085064z
nes$V085065a[nes$V085065a=="-2"] <- NA nes$V085065a[nes$V085065a=="-6"] <- NA nes$V085065a[nes$V085065a=="-8"] <- NA nes$V085065a[nes$V085065a=="-9"] <- NA undocumented<-nes$V085065a
nes$V085065b[nes$V085065b=="-2"] <- NA nes$V085065b[nes$V085065b=="-6"] <- NA nes$V085065b[nes$V085065b=="-8"] <- NA nes$V085065b[nes$V085065b=="-9"] <- NA richppl<-nes$V085065b
nes$V085065c[nes$V085065c=="-2"] <- NA nes$V085065c[nes$V085065c=="-6"] <- NA nes$V085065c[nes$V085065c=="-8"] <- NA nes$V085065c[nes$V085065c=="-9"] <- NA whiteppl<-nes$V085065c
nes$V085065e[nes$V085065e=="-2"] <- NA nes$V085065e[nes$V085065e=="-6"] <- NA nes$V085065e[nes$V085065e=="-8"] <- NA nes$V085065e[nes$V085065e=="-9"] <- NA muslims<-nes$V085065e
nes$V085065g[nes$V085065g=="-2"] <- NA nes$V085065g[nes$V085065g=="-6"] <- NA nes$V085065g[nes$V085065g=="-8"] <- NA nes$V085065g[nes$V085065g=="-9"] <- NA christians<-nes$V085065g
nes$V085065h[nes$V085065h=="-2"] <- NA nes$V085065h[nes$V085065h=="-6"] <- NA nes$V085065h[nes$V085065h=="-8"] <- NA nes$V085065h[nes$V085065h=="-9"] <- NA atheists<-nes$V085065h
nes$V085072[nes$V085072=="-1. INAP, R selected for VERSION NEW"] <- NA nes$V085072[nes$V085072=="-2. No Post-election IW"] <- NA nes$V085072[nes$V085072=="-8. Don't know"] <- NA nes$V085072[nes$V085072=="-9. Refused"] <- NA interest<-nes$V085072
nes$V083215x[nes$V083215x=="-4"] <- NA nes$V083215x[nes$V083215x=="-8"] <- NA nes$V083215x[nes$V083215x=="-9"] <- NA age<-nes$V083215x
nes$V083007[nes$V083007=="-8. Don't know"] <- NA nes$V083007[nes$V083007=="-9. Refused"] <- NA voted2004<-nes$V083007
nes$V083018[nes$V083018=="-8. Don't know"] <- NA nes$V083018[nes$V083018=="-9. Refused"] <- NA internet<-nes$V083018
nes$V083019[nes$V083019=="-1. INAP, R selected for version NEW"] <- NA nes$V083019[nes$V083019=="-8. Don't know"] <- NA nes$V083019[nes$V083019=="-9. Refused"] <- NA tvnewsdays<-nes$V083019
nes$V083019a[nes$V083019a=="-1. INAP, R selected for version NEW; 0,-8,-9 in A11b"] <- NA nes$V083019a[nes$V083019a=="-8. Don't know"] <- NA nes$V083019a[nes$V083019a=="-9. Refused"] <- NA tvnewsattention<-nes$V083019a
nes$V083027[nes$V083027=="-8. Don't know"] <- NA nes$V083027[nes$V083027=="-9. Refused"] <- NA righttrack<-nes$V083027
nes$V083097[nes$V083097=="-8. Don't know"] <- NA nes$V083097[nes$V083097=="-9. Refused"] <- NA partyid<-nes$V083097
nes$V081102[nes$V081102=="-4. NA (blank recorded)"] <- NA nes$V081102[nes$V081102=="-9. Refused in household listing"] <- NA nes$V081102[nes$V081102=="6. Black and another race"] <- NA nes$V081102[nes$V081102=="5. White and another race"] <- NA nes$V081102[nes$V081102=="7. White, black and another race"] <- NA race<-nes$V081102 #-------My Analyses------#
For my redo of my midterm I have fixed the images so that they can be seen by others.
My hypothesis is that the data I am analyzing will show that overall people feel "warmer" towards "whiteppl" than they do "blacks." Through box plots, violin plots, histograms, and kernel density plots; this hypothesis proves to be true. I also have added a regression analysis.
Boxplot:
The two boxplots show how "warmly" or "coldly" people feel towards white and black people. The magenta graph is representative of "whiteppl" and the blue graph is representative of "blacks." There are a couple of outliers on the blue graph which means that some people feel extremely cold towards black people. However, the median of the graph is around 50 which means that 50% of people felt colder than that, and 50% felt warmer. On the magenta graph, it shows that the median is around 70. Overall, according to the graph people felt more warmly towards white people than black people.
Violin Plot
The violin plots show that a greater number of people felt warmly towards white people (magenta graph) than black people (blue graph).
Histogram of "Blacks"
This histogram shows the frequency of people's responses when asked how warmly they felt towards "blacks." The bars that are the tallest show that a large amount of people gave this response.
Histogram of "Whiteppl"
This histogram shows the frequency of people's responses when asked how warmly they felt towards "whiteppl." The bars that are the tallest show that a large amount of people gave this response.
Scatter Plot
This scatterplot shows the relationship between the two variables "blacks" and "whiteppl."
Kernel Density Plot of "Whiteppl"
Kernel Density Plot of "Blacks"
Descriptive Statistics
“Blacks”
Median- 70.00
Mean- 72.04
Variance- 426.38
Standard Deviation- 20.65
Coefficient Variance- 0.29
Minimum- 0
Maximum- 100
Descriptive Statistics
“Whiteppl”
Median- 70.00
Mean- 73.32
Variance- 379.76
Standard Deviation- 19.49
Coeficient Variance- 0.29
Minimum- 0
Maximum- 100
Correlation between data on variables "Whiteppl" and "Blacks"
0.52
Regression Analysis
shows that there is in fact a statistically significant relationship between how people feel towards "blacks" and how people feel towards "whiteppl" ("warm" or "cold").
#This R Script finds Descriptive Statistics for the variables “whiteppl” and “blacks,” finds the correlation between the two variables, and also creates boxplots, violin plots, histograms, and scatter plots for both variables.
#R SCRIPT
install.packages("foreign") #install package to read in .dta files
library(foreign) #load it
nes<-read.dta("anes2008.dta") #read in data file from working directory,
#and call it "nes". Takes a minute.
nes$V085064k[nes$V085064k=="-2"] <- NA #for each selected variable, replace
nes$V085064k[nes$V085064k=="-6"] <- NA #negative values with "NA" and
nes$V085064k[nes$V085064k=="-8"] <- NA #generate new variable with
nes$V085064k[nes$V085064k=="-9"] <- NA #more intuitive name!
poorppl<-nes$V085064k
nes$V085064n[nes$V085064n=="-2"] <- NA
nes$V085064n[nes$V085064n=="-6"] <- NA
nes$V085064n[nes$V085064n=="-8"] <- NA
nes$V085064n[nes$V085064n=="-9"] <- NA
bigbiz<-nes$V085064n
nes$V085064p[nes$V085064p=="-2"] <- NA
nes$V085064p[nes$V085064p=="-6"] <- NA
nes$V085064p[nes$V085064p=="-8"] <- NA
nes$V085064p[nes$V085064p=="-9"] <- NA
welfareppl<-nes$V085064p
nes$V085064d[nes$V085064d=="-2"] <- NA
nes$V085064d[nes$V085064d=="-6"] <- NA
nes$V085064d[nes$V085064d=="-8"] <- NA
nes$V085064d[nes$V085064d=="-9"] <- NA
feminists<-nes$V085064d
nes$V085064b[nes$V085064b=="-2"] <- NA
nes$V085064b[nes$V085064b=="-6"] <- NA
nes$V085064b[nes$V085064b=="-8"] <- NA
nes$V085064b[nes$V085064b=="-9"] <- NA
cfundamentals<-nes$V085064b
nes$V085064e[nes$V085064e=="-2"] <- NA
nes$V085064e[nes$V085064e=="-6"] <- NA
nes$V085064e[nes$V085064e=="-8"] <- NA
nes$V085064e[nes$V085064e=="-9"] <- NA
fedgov<-nes$V085064e
nes$V085064h[nes$V085064h=="-2"] <- NA
nes$V085064h[nes$V085064h=="-6"] <- NA
nes$V085064h[nes$V085064h=="-8"] <- NA
nes$V085064h[nes$V085064h=="-9"] <- NA
midclass<-nes$V085064h
nes$V085064m[nes$V085064m=="-2"] <- NA
nes$V085064m[nes$V085064m=="-6"] <- NA
nes$V085064m[nes$V085064m=="-8"] <- NA
nes$V085064m[nes$V085064m=="-9"] <- NA
military<-nes$V085064m
nes$V085064r[nes$V085064r=="-2"] <- NA
nes$V085064r[nes$V085064r=="-6"] <- NA
nes$V085064r[nes$V085064r=="-8"] <- NA
nes$V085064r[nes$V085064r=="-9"] <- NA
workclass<-nes$V085064r
nes$V085064u[nes$V085064u=="-2"] <- NA
nes$V085064u[nes$V085064u=="-6"] <- NA
nes$V085064u[nes$V085064u=="-8"] <- NA
nes$V085064u[nes$V085064u=="-9"] <- NA
gays<-nes$V085064u
nes$V085064v[nes$V085064v=="-2"] <- NA
nes$V085064v[nes$V085064v=="-6"] <- NA
nes$V085064v[nes$V085064v=="-8"] <- NA
nes$V085064v[nes$V085064v=="-9"] <- NA
asians<-nes$V085064v
nes$V085064y[nes$V085064y=="-2"] <- NA
nes$V085064y[nes$V085064y=="-6"] <- NA
nes$V085064y[nes$V085064y=="-8"] <- NA
nes$V085064y[nes$V085064y=="-9"] <- NA
blacks<-nes$V085064y
nes$V085064z[nes$V085064z=="-2"] <- NA
nes$V085064z[nes$V085064z=="-6"] <- NA
nes$V085064z[nes$V085064z=="-8"] <- NA
nes$V085064z[nes$V085064z=="-9"] <- NA
southerners<-nes$V085064z
nes$V085065a[nes$V085065a=="-2"] <- NA
nes$V085065a[nes$V085065a=="-6"] <- NA
nes$V085065a[nes$V085065a=="-8"] <- NA
nes$V085065a[nes$V085065a=="-9"] <- NA
undocumented<-nes$V085065a
nes$V085065b[nes$V085065b=="-2"] <- NA
nes$V085065b[nes$V085065b=="-6"] <- NA
nes$V085065b[nes$V085065b=="-8"] <- NA
nes$V085065b[nes$V085065b=="-9"] <- NA
richppl<-nes$V085065b
nes$V085065c[nes$V085065c=="-2"] <- NA
nes$V085065c[nes$V085065c=="-6"] <- NA
nes$V085065c[nes$V085065c=="-8"] <- NA
nes$V085065c[nes$V085065c=="-9"] <- NA
whiteppl<-nes$V085065c
nes$V085065e[nes$V085065e=="-2"] <- NA
nes$V085065e[nes$V085065e=="-6"] <- NA
nes$V085065e[nes$V085065e=="-8"] <- NA
nes$V085065e[nes$V085065e=="-9"] <- NA
muslims<-nes$V085065e
nes$V085065g[nes$V085065g=="-2"] <- NA
nes$V085065g[nes$V085065g=="-6"] <- NA
nes$V085065g[nes$V085065g=="-8"] <- NA
nes$V085065g[nes$V085065g=="-9"] <- NA
christians<-nes$V085065g
nes$V085065h[nes$V085065h=="-2"] <- NA
nes$V085065h[nes$V085065h=="-6"] <- NA
nes$V085065h[nes$V085065h=="-8"] <- NA
nes$V085065h[nes$V085065h=="-9"] <- NA
atheists<-nes$V085065h
nes$V085072[nes$V085072=="-1. INAP, R selected for VERSION NEW"] <- NA
nes$V085072[nes$V085072=="-2. No Post-election IW"] <- NA
nes$V085072[nes$V085072=="-8. Don't know"] <- NA
nes$V085072[nes$V085072=="-9. Refused"] <- NA
interest<-nes$V085072
nes$V083215x[nes$V083215x=="-4"] <- NA
nes$V083215x[nes$V083215x=="-8"] <- NA
nes$V083215x[nes$V083215x=="-9"] <- NA
age<-nes$V083215x
nes$V083007[nes$V083007=="-8. Don't know"] <- NA
nes$V083007[nes$V083007=="-9. Refused"] <- NA
voted2004<-nes$V083007
nes$V083018[nes$V083018=="-8. Don't know"] <- NA
nes$V083018[nes$V083018=="-9. Refused"] <- NA
internet<-nes$V083018
nes$V083019[nes$V083019=="-1. INAP, R selected for version NEW"] <- NA
nes$V083019[nes$V083019=="-8. Don't know"] <- NA
nes$V083019[nes$V083019=="-9. Refused"] <- NA
tvnewsdays<-nes$V083019
nes$V083019a[nes$V083019a=="-1. INAP, R selected for version NEW; 0,-8,-9 in A11b"] <- NA
nes$V083019a[nes$V083019a=="-8. Don't know"] <- NA
nes$V083019a[nes$V083019a=="-9. Refused"] <- NA
tvnewsattention<-nes$V083019a
nes$V083027[nes$V083027=="-8. Don't know"] <- NA
nes$V083027[nes$V083027=="-9. Refused"] <- NA
righttrack<-nes$V083027
nes$V083097[nes$V083097=="-8. Don't know"] <- NA
nes$V083097[nes$V083097=="-9. Refused"] <- NA
partyid<-nes$V083097
nes$V081102[nes$V081102=="-4. NA (blank recorded)"] <- NA
nes$V081102[nes$V081102=="-9. Refused in household listing"] <- NA
nes$V081102[nes$V081102=="6. Black and another race"] <- NA
nes$V081102[nes$V081102=="5. White and another race"] <- NA
nes$V081102[nes$V081102=="7. White, black and another race"] <- NA
race<-nes$V081102
#-------My Analyses------#
install.packages("pastecs")
library(pastecs)
stat.desc(whiteppl, basic=FALSE)
stat.desc(blacks, basic=FALSE)
summary(whiteppl)
summary(blacks)
install.packages("wvioplot")
library(wvioplot)
par(mfrow=c(1,2))
wvioplot(whiteppl, col="magenta", names="whiteppl")
wvioplot(blacks, col="blue", names="blackppl")
par(mfrow=c(1,2))
boxplot(whiteppl, col="magenta")
boxplot(blacks, col="blue")
install.packages("car")
library(car)
scatterplot(whiteppl, blacks)
hist(whiteppl)
hist(blacks)
whiteppl<-as.numeric(whiteppl)
blacks<-as.numeric(blacks)
cor(whiteppl, blacks, use="complete.obs")
plot(density(whiteppl,na.rm=TRUE))
plot(density(blacks,na.rm=TRUE))
table <- table(whiteppl, blacks)
reg <- lm(whiteppl ~ blacks)
summary(reg)